home *** CD-ROM | disk | FTP | other *** search
/ Chip: Internet / Chip Internet.iso / viewer / ghost / init.c < prev    next >
C/C++ Source or Header  |  1993-07-27  |  18KB  |  515 lines

  1. /*
  2.  * init.c   -- Initialisation functions for GSVIEW.EXE,
  3.  *             a graphical interface for MS-Windows Ghostscript
  4.  * Copyright (C) 1993  Russell Lang
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  *   Author: Russell Lang
  21.  * Internet: rjl@monu1.cc.monash.edu.au
  22.  */
  23.  
  24. #define STRICT
  25. #include <windows.h>
  26. #include <windowsx.h>
  27. #include <commdlg.h>
  28. #include <shellapi.h>
  29. #include <mmsystem.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <ctype.h>
  34. #include <dir.h>
  35. #include <io.h>
  36. #define NeedFunctionPrototypes 1
  37. #include "ps.h"
  38. #include "gsview.h"
  39.  
  40. /* Open/Save File Dialog Box */
  41. OPENFILENAME ofn;
  42. char szOFilename[MAXSTR];    /* filename for OFN */
  43. char szOFilter[256];        /* filter for OFN */
  44. /* buttons */
  45. WNDPROC lpfnButtonWndProc;    /* default button WndProc */
  46. struct buttonlist {
  47.    HWND hbutton;
  48.    struct buttonlist *next;
  49. };
  50. struct buttonlist *buttonhead, *buttontail;
  51. int real_button_width;
  52.  
  53. /* Don't start another instance - use previous instance */
  54. void
  55. gsview_init0(LPSTR lpszCmdLine)
  56. {
  57.     HWND hwnd = FindWindow(szClassName, szAppName);
  58.     BringWindowToTop(hwnd);
  59.     if (lstrlen(lpszCmdLine) != 0) {
  60.         /* open file specified on command line */
  61.         LPSTR szFile = GlobalAllocPtr(GHND | GMEM_SHARE, lstrlen(lpszCmdLine)+1);
  62.         if (szFile) {
  63.         lstrcpy(szFile, lpszCmdLine);
  64.         PostMessage(hwnd, WM_COMMAND, IDM_DROP, (LPARAM)szFile);
  65.         }
  66.     }
  67. }
  68.  
  69. /* main initialisation */
  70. void
  71. gsview_init1(LPSTR lpszCmdLine)
  72. {
  73. WNDCLASS wndclass;
  74. WORD version = LOWORD(GetVersion());
  75. char *p;
  76. char workdir[MAXSTR];
  77. char filedir[MAXSTR];
  78. int length = 64;
  79.  
  80.     while (length && !SetMessageQueue(length))
  81.         length--;    /* reduce size and try again */
  82.     if (length == 0)
  83.         exit(0);    /* panic */
  84.     
  85.     if ((LOBYTE(version)<<8) + HIBYTE(version) >= 0x30a)
  86.         is_win31 = TRUE;
  87.  
  88.     /* get path to help file */
  89.     GetModuleFileName(phInstance, szHelpName, sizeof(szHelpName));
  90.     if ((p = strrchr(szHelpName,'\\')) != (char *)NULL)
  91.         p++;
  92.     else
  93.         p = szHelpName;
  94.     LoadString(phInstance, IDS_HELPFILE, p, sizeof(szHelpName) - (p-szHelpName));
  95.  
  96.     /* help message for GetOpenFileName Dialog Box */
  97.     help_message = RegisterWindowMessage(HELPMSGSTRING);
  98.     LoadString(phInstance, IDS_TOPICROOT, szHelpTopic, sizeof(szHelpTopic));
  99.     
  100.     /* register the window class */
  101.     wndclass.style = CS_HREDRAW | CS_VREDRAW;
  102.     wndclass.lpfnWndProc = WndImgProc;
  103.     wndclass.cbClsExtra = 0;
  104.     wndclass.cbWndExtra = sizeof(LONG);
  105.     wndclass.hInstance = phInstance;
  106.     wndclass.hIcon = LoadIcon(phInstance,"gsview");
  107.     wndclass.hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW);
  108.     wndclass.hbrBackground =  GetStockObject(WHITE_BRUSH);
  109.     wndclass.lpszMenuName = NULL;
  110.     wndclass.lpszClassName = szClassName;
  111.     RegisterClass(&wndclass);
  112.  
  113.     /* defaults if entry not in gsview.ini */
  114.     strcpy(szGSwin, DEFAULT_GSCOMMAND);
  115.     img_origin.x = img_origin.y = CW_USEDEFAULT;
  116.     img_size.x = img_size.y = CW_USEDEFAULT;
  117.     xdpi = ydpi = DEFAULT_RESOLUTION;
  118.     button_show = TRUE;
  119.     epsf_clip = FALSE;
  120.     epsf_warn = FALSE;
  121.     media = IDM_LETTER;
  122.     quick = TRUE;
  123.         redisplay = FALSE;
  124.     safer = TRUE;
  125.     save_dir = TRUE;
  126.     settings = TRUE;
  127.     timeout = DEFAULT_TIMEOUT;
  128.     orientation = IDM_PORTRAIT;
  129.     swap_landscape = FALSE;
  130.     hmenu = LoadMenu(phInstance, "gsview_menu");
  131.     GetMenuString(hmenu, media, medianame, sizeof(medianame), MF_BYCOMMAND);
  132.     haccel = LoadAccelerators(phInstance, "gsview_accel");
  133.     getcwd(workdir, sizeof(workdir));
  134.     /* read entries from gsview.ini */
  135.     read_profile();
  136.  
  137.     hwndimg = CreateWindow(szClassName, (LPSTR)szAppName,
  138.           WS_OVERLAPPEDWINDOW,
  139.           img_origin.x, img_origin.y, 
  140.           img_size.x, img_size.y, 
  141.           NULL, NULL, phInstance, (void FAR *)NULL);
  142.  
  143.     /* load DLL for sounds */
  144.     if (is_win31) {
  145.         /* MMSYSTEM.DLL requires Windows 3.1, so to allow gsview to run
  146.            under Windows 3.0 we can't use the import library */
  147.         hlib_mmsystem = LoadLibrary("MMSYSTEM.DLL");
  148.         if (hlib_mmsystem >= HINSTANCE_ERROR) {
  149.         lpfnSndPlaySound = (FPSPS)GetProcAddress(hlib_mmsystem, "sndPlaySound");
  150.         }
  151.         else {
  152.         gserror(IDS_SOUNDNOMM, NULL, MB_ICONEXCLAMATION, -1);
  153.         hlib_mmsystem = (HINSTANCE)NULL;
  154.         }
  155.     }
  156.  
  157.     if (lstrlen(lpszCmdLine) >= 2) {
  158.         if ( ((lpszCmdLine[0] == '/') || (lpszCmdLine[0] == '-'))
  159.          &&  ((lpszCmdLine[1] == 'D') || (lpszCmdLine[1] == 'd')) ) {
  160.         debug = TRUE;
  161.         lpszCmdLine += 2;
  162.         while (*lpszCmdLine && (*lpszCmdLine == ' '))
  163.             lpszCmdLine++;
  164.         }
  165.      }
  166.     if (lstrlen(lpszCmdLine) != 0) {
  167.         /* open file specified on command line */
  168.         LPSTR szFile = GlobalAllocPtr(GHND, lstrlen(lpszCmdLine)+1);
  169.         if (szFile) {
  170.         lstrcpy(szFile, lpszCmdLine);
  171.         PostMessage(hwndimg, WM_COMMAND, IDM_DROP, (LPARAM)szFile);
  172.         }
  173.         /* ignore last saved directory */
  174.         /* use directory of file if given, or work directory */
  175.         if ((lpszCmdLine[0] == '/') || (lpszCmdLine[0] == '-')) {
  176.         lpszCmdLine += 2;
  177.         while (*lpszCmdLine && (*lpszCmdLine == ' '))
  178.             lpszCmdLine++;
  179.         }
  180.         lstrcpy(filedir, lpszCmdLine);
  181.         if ( (p = strrchr(filedir, '\\')) == (char *)NULL ) {
  182.             if ( (p = strrchr(filedir, ':')) == (char *)NULL )
  183.             strcpy(filedir, workdir);  /* no path so use work directory */
  184.         else
  185.             *(++p) = '\0';
  186.         }
  187.         else
  188.         *(++p) = '\0';
  189.         if (!((strlen(filedir)==2) && isalpha(filedir[0]) && (filedir[1]==':')))
  190.             chdir(filedir);
  191.         if (isalpha(filedir[0]) && (filedir[1]==':'))
  192.         (void) setdisk(toupper(filedir[0])-'A');
  193.     }
  194.     play_sound(SOUND_START);
  195. }
  196.  
  197. /* create gsview window menu bar and buttons */
  198. void
  199. gsview_create()
  200. {
  201. int i;
  202. char cReplace;
  203. WNDCLASS wndclass;
  204. HGLOBAL hglobal;
  205. int FAR *pButtonID;
  206. TEXTMETRIC tm;
  207. HDC hdc;
  208. HWND hbutton;
  209. WNDPROC    lpfnMenuButtonProc;
  210. POINT char_size;        /* size of default text characters */
  211. POINT button_size, button_shift;
  212.  
  213.     /* setup OPENFILENAME struct */
  214.     if (!LoadString(phInstance, IDS_FILTER, szOFilter, sizeof(szOFilter)-1))
  215.         return;
  216.     cReplace = szOFilter[strlen(szOFilter)-1];
  217.     for (i=0; szOFilter[i] != '\0'; i++)
  218.         if (szOFilter[i] == cReplace)
  219.         szOFilter[i] = '\0';
  220.     ofn.lStructSize = sizeof(OPENFILENAME);
  221.     ofn.hwndOwner = hwndimg;
  222.     ofn.lpstrFilter = szOFilter;
  223.     ofn.nFilterIndex = FILTER_PS;
  224.     ofn.lpstrFile = szOFilename;
  225.     ofn.nMaxFile = sizeof(szOFilename);
  226.     ofn.lpstrFileTitle = (LPSTR)NULL;
  227.     ofn.nMaxFileTitle = 0;
  228.     ofn.lpstrTitle = (LPSTR)NULL;
  229.     ofn.lpstrInitialDir = (LPSTR)NULL;
  230.     ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_SHOWHELP;
  231.     LoadString(phInstance, IDS_TOPICROOT, szHelpTopic, sizeof(szHelpTopic));
  232.  
  233.     /* add menu to image window */
  234.     SetMenu(hwndimg, hmenu);
  235.  
  236.     /* get default text size */
  237.     hdc = GetDC(hwndimg);
  238.     GetTextMetrics(hdc,(LPTEXTMETRIC)&tm);
  239.     ReleaseDC(hwndimg,hdc);
  240.     char_size.x = tm.tmAveCharWidth;
  241.     char_size.y = tm.tmHeight;
  242.  
  243.     /* set size of info area, buttons and offset to child window */
  244.     info_rect.left = 0;
  245.     info_rect.right = info_rect.left + 60 * char_size.x;
  246.     info_rect.top = 0;
  247.     info_rect.bottom = char_size.y;
  248.     button_size.x = 24;
  249.     button_size.y = 24;
  250.     button_shift.x = 0;
  251.     button_shift.y = button_size.y - 1;
  252.     button_rect.top = info_rect.bottom;
  253.     button_rect.left = -1;
  254.     button_rect.right = button_size.x - 2;
  255.     button_rect.bottom = 0;        /* don't care */
  256.     real_button_width = button_rect.right;
  257.     if (!button_show)
  258.         button_rect.right = 0;
  259.     img_offset.x = button_rect.right + (button_show ? 1 : 0);
  260.     img_offset.y = info_rect.bottom + 1;
  261.     info_file.x = info_rect.left + 2;
  262.     info_file.y = 0;
  263.     info_page.x = info_rect.left + 34 * char_size.x + 2;
  264.     info_page.y = 0;
  265.     info_coord.left = info_rect.left + 20 * char_size.x;
  266.     info_coord.right = info_rect.left + 32 * char_size.x;
  267.     info_coord.top = 0;
  268.     info_coord.bottom = char_size.y;
  269.  
  270.     /* check menu items */
  271.     CheckMenuItem(hmenu, media, MF_BYCOMMAND | MF_CHECKED);
  272.     CheckMenuItem(hmenu, orientation, MF_BYCOMMAND | MF_CHECKED);
  273.     if (epsf_clip)
  274.         CheckMenuItem(hmenu, IDM_EPSFCLIP, MF_BYCOMMAND | MF_CHECKED);
  275.     if (epsf_warn)
  276.         CheckMenuItem(hmenu, IDM_EPSFWARN, MF_BYCOMMAND | MF_CHECKED);
  277.     if (swap_landscape)
  278.         CheckMenuItem(hmenu, IDM_SWAPLANDSCAPE, MF_BYCOMMAND | MF_CHECKED);
  279.     if (save_dir) 
  280.         CheckMenuItem(hmenu, IDM_SAVEDIR, MF_BYCOMMAND | MF_CHECKED);
  281.     if (button_show) 
  282.         CheckMenuItem(hmenu, IDM_BUTTONSHOW, MF_BYCOMMAND | MF_CHECKED);
  283.     if (quick) 
  284.         CheckMenuItem(hmenu, IDM_QUICK, MF_BYCOMMAND | MF_CHECKED);
  285.     if (safer) 
  286.         CheckMenuItem(hmenu, IDM_SAFER, MF_BYCOMMAND | MF_CHECKED);
  287.     if (redisplay) 
  288.         CheckMenuItem(hmenu, IDM_AUTOREDISPLAY, MF_BYCOMMAND | MF_CHECKED);
  289.     if (settings)
  290.         CheckMenuItem(hmenu, IDM_SAVESETTINGS, MF_BYCOMMAND | MF_CHECKED);
  291.  
  292.     hcWait = LoadCursor((HINSTANCE)NULL, IDC_WAIT);
  293.  
  294.     /* add buttons */
  295.     lpfnMenuButtonProc = (WNDPROC)MakeProcInstance((FARPROC)MenuButtonProc, phInstance);
  296.     GetClassInfo((HINSTANCE)NULL, "button", &wndclass);    /* get default button class info */
  297.     lpfnButtonWndProc = wndclass.lpfnWndProc;
  298.     
  299.     hglobal = LoadResource(phInstance, FindResource(phInstance, "gsview_button", RT_RCDATA));
  300.     if ( (pButtonID = (int FAR *)LockResource(hglobal)) == (int FAR *)NULL)
  301.         return;
  302.     
  303.     for (i=0; pButtonID[i]; i++) {
  304.         hbutton = CreateWindow("button", NULL,
  305.             WS_CHILD | (button_show ? WS_VISIBLE : 0) | BS_OWNERDRAW,
  306.             button_rect.left + i * button_shift.x,
  307.             button_rect.top  + i * button_shift.y,
  308.             button_size.x, button_size.y,
  309.             hwndimg, (HMENU)pButtonID[i],
  310.             phInstance, NULL);
  311.         SetWindowLong(hbutton, GWL_WNDPROC, (LONG)lpfnMenuButtonProc);
  312.         if (hbutton) {
  313.         if (buttonhead == (struct buttonlist *)NULL)
  314.             buttontail = buttonhead = (struct buttonlist *)malloc(sizeof(struct buttonlist));
  315.         else {
  316.             buttontail->next = (struct buttonlist *)malloc(sizeof(struct buttonlist)); 
  317.             buttontail = buttontail->next;
  318.         }
  319.         buttontail->hbutton = hbutton;
  320.         buttontail->next = NULL;
  321.         }
  322.     }
  323.     FreeResource(hglobal);
  324. }
  325.  
  326. void
  327. show_buttons(void)
  328. {
  329. struct buttonlist *bp = buttonhead;
  330. RECT rect;
  331.     button_rect.right = button_show ? real_button_width : 0;
  332.     img_offset.x = button_rect.right + (button_show ? 1 : 0);
  333.     if (!button_show) {
  334.         while (bp) {
  335.             ShowWindow(bp->hbutton, SW_HIDE);
  336.             bp = bp->next;
  337.         }
  338.         if (hwndimgchild == (HWND)NULL) {
  339.             GetClientRect(hwndimg, &rect);
  340.             rect.right = real_button_width + 1;
  341.             rect.top = button_rect.top;
  342.             InvalidateRect(hwndimg, &rect, TRUE);
  343.             UpdateWindow(hwndimg);
  344.         }
  345.     }
  346.     GetClientRect(hwndimg, &rect);
  347.     SetWindowPos(hwndimgchild, (HWND)NULL, rect.left+img_offset.x, rect.top+img_offset.y,
  348.         rect.right-img_offset.x, rect.bottom-img_offset.y, 
  349.         SWP_NOZORDER | SWP_NOACTIVATE);
  350.     rect.right = real_button_width + 1;
  351.     rect.top = button_rect.top;
  352.     if (button_show) {
  353.         InvalidateRect(hwndimg, &rect, FALSE);
  354.         UpdateWindow(hwndimg);
  355.         while (bp) {
  356.             ShowWindow(bp->hbutton, SW_SHOWNA);
  357.             bp = bp->next;
  358.         }
  359.     }
  360. }
  361.  
  362. /* read settings fron INI file */
  363. void
  364. read_profile()
  365. {
  366. int i;
  367. char profile[128];
  368. LPSTR file = INIFILE;
  369. LPSTR section = INISECTION;
  370.     GetPrivateProfileString(section, "Origin", "", profile, sizeof(profile), file);
  371.     if (sscanf(profile,"%d %d", &img_origin.x, &img_origin.y) != 2) {
  372.         img_origin.x = CW_USEDEFAULT;
  373.         img_origin.y = CW_USEDEFAULT;
  374.     }
  375.     GetPrivateProfileString(section, "Size", "", profile, sizeof(profile), file);
  376.     if (sscanf(profile,"%d %d", &img_size.x, &img_size.y) != 2) {
  377.         img_origin.x = CW_USEDEFAULT;
  378.         img_origin.y = CW_USEDEFAULT;
  379.     }
  380.     GetPrivateProfileString(section, "SaveSettings", "", profile, sizeof(profile), file);
  381.     if (sscanf(profile,"%d", &i) == 1)
  382.         settings = i;
  383.     GetPrivateProfileString(section, "ButtonBar", "", profile, sizeof(profile), file);
  384.     if (sscanf(profile,"%d", &i) == 1)
  385.         button_show = i;
  386.     GetPrivateProfileString(section, "Resolution", "", profile, sizeof(profile), file);
  387.     if (sscanf(profile,"%f %f", &xdpi, &ydpi) != 2) {
  388.         xdpi = DEFAULT_RESOLUTION;
  389.         ydpi = DEFAULT_RESOLUTION;
  390.     }
  391.     GetPrivateProfileString(section, "Media", "", profile, sizeof(profile), file);
  392.     if (strlen(profile)!=0) {
  393.         char thismedia[20];
  394.         for (i=IDM_LETTER; i<IDM_USERSIZE; i++) {
  395.             GetMenuString(hmenu, i, thismedia, sizeof(thismedia), MF_BYCOMMAND);
  396.             if (!stricmp(thismedia, profile)) {
  397.                 break;
  398.             }
  399.         }
  400.         media = i;
  401.         strncpy(medianame,thismedia,sizeof(medianame));
  402.         }
  403.     GetPrivateProfileString(section, "UserSize", "", profile, sizeof(profile), file);
  404.     if (sscanf(profile,"%d %d", &user_width, &user_height) != 2) {
  405.         /* this gives 640x480 pixels at 96dpi */
  406.         user_width = 480;
  407.         user_height = 360;
  408.     }
  409.     GetPrivateProfileString(section, "EpsfClip", "", profile, sizeof(profile), file);
  410.     if (sscanf(profile,"%d", &i) == 1)
  411.         epsf_clip = i;
  412.     GetPrivateProfileString(section, "EpsfWarn", "", profile, sizeof(profile), file);
  413.     if (sscanf(profile,"%d", &i) == 1)
  414.         epsf_warn = i;
  415.     GetPrivateProfileString(section, "Orientation", "", profile, sizeof(profile), file);
  416.     if (sscanf(profile,"%d", &i) == 1)
  417.         orientation = i+IDM_PORTRAIT;
  418.     GetPrivateProfileString(section, "SwapLandscape", "", profile, sizeof(profile), file);
  419.     if (sscanf(profile,"%d", &i) == 1)
  420.         swap_landscape = i;
  421.     GetPrivateProfileString(section, "QuickOpen", "", profile, sizeof(profile), file);
  422.     if (sscanf(profile,"%d", &i) == 1)
  423.         quick = i;
  424.     GetPrivateProfileString(section, "Safer", "", profile, sizeof(profile), file);
  425.     if (sscanf(profile,"%d", &i) == 1)
  426.         safer = i;
  427.     GetPrivateProfileString(section, "AutoRedisplay", "", profile, sizeof(profile), file);
  428.     if (sscanf(profile,"%d", &i) == 1)
  429.         redisplay = i;
  430.     GetPrivateProfileString(section, "Timeout", "", profile, sizeof(profile), file);
  431.     if (sscanf(profile,"%d", &i) == 1)
  432.         timeout = i;
  433.     if (timeout == 0)
  434.         timeout = 120;
  435.     GetPrivateProfileString(section, "SaveLastDir", "", profile, sizeof(profile), file);
  436.     if (sscanf(profile,"%d", &i) == 1)
  437.         save_dir = i;
  438.     if (save_dir) {
  439.         GetPrivateProfileString(section, "LastDir", "", profile, sizeof(profile), file);
  440.         if (!((strlen(profile)==2) && isalpha(profile[0]) && (profile[1]==':')))
  441.             chdir(profile);
  442.         if (isalpha(profile[0]) && (profile[1]==':'))
  443.         (void) setdisk(toupper(profile[0])-'A');
  444.     }
  445.     GetPrivateProfileString(section, "Ghostscript", "", profile, sizeof(profile), file);
  446.     if (profile[0] == '\0')
  447.         strcpy(szGSwin, DEFAULT_GSCOMMAND);
  448.     else
  449.         strcpy(szGSwin, profile);
  450.     GetPrivateProfileString(section, "Printer", ",", profile, sizeof(profile), file);
  451.     strcpy(device_name, strtok(profile,","));
  452.     strcpy(device_resolution, strtok(NULL, ","));
  453.     for (i=0; i<NUMSOUND; i++) {
  454.         GetPrivateProfileString(section, sound[i].entry, sound[i].file, profile, sizeof(profile), file);
  455.         strcpy(sound[i].file, profile);
  456.     }
  457. }
  458.  
  459. /* write settings to INI file */
  460. void
  461. write_profile()
  462. {
  463. char profile[MAXSTR];
  464. LPSTR file = INIFILE;
  465. LPSTR section = INISECTION;
  466. int i;
  467.     sprintf(profile, "%d %d", img_origin.x, img_origin.y);
  468.     WritePrivateProfileString(section, "Origin", profile, file);
  469.     sprintf(profile, "%d %d", img_size.x, img_size.y);
  470.     WritePrivateProfileString(section, "Size", profile, file);
  471.     sprintf(profile, "%d", settings);
  472.     WritePrivateProfileString(section, "SaveSettings", profile, file);
  473.     sprintf(profile, "%d", button_show);
  474.     WritePrivateProfileString(section, "ButtonBar", profile, file);
  475.     sprintf(profile, "%g %g", xdpi, ydpi);
  476.     WritePrivateProfileString(section, "Resolution", profile, file);
  477.     if (media == IDM_USERSIZE)
  478.         strcpy(profile, "User Defined");
  479.     else
  480.         strcpy(profile, medianame);
  481.     WritePrivateProfileString(section, "Media", profile, file);
  482.     sprintf(profile, "%u %u", user_width, user_height);
  483.     WritePrivateProfileString(section, "UserSize", profile, file);
  484.     sprintf(profile, "%d", epsf_clip);
  485.     WritePrivateProfileString(section, "EpsfClip", profile, file);
  486.     sprintf(profile, "%d", epsf_warn);
  487.     WritePrivateProfileString(section, "EpsfWarn", profile, file);
  488.     sprintf(profile, "%d", orientation - IDM_PORTRAIT);
  489.     WritePrivateProfileString(section, "Orientation", profile, file);
  490.     sprintf(profile, "%d", swap_landscape);
  491.     WritePrivateProfileString(section, "SwapLandscape", profile, file);
  492.     sprintf(profile, "%d", quick);
  493.     WritePrivateProfileString(section, "QuickOpen", profile, file);
  494.     sprintf(profile, "%d", safer);
  495.     WritePrivateProfileString(section, "Safer", profile, file);
  496.     sprintf(profile, "%d", redisplay);
  497.     WritePrivateProfileString(section, "AutoRedisplay", profile, file);
  498.     sprintf(profile, "%d", timeout);
  499.     WritePrivateProfileString(section, "Timeout", profile, file);
  500.     sprintf(profile, "%d", save_dir);
  501.     WritePrivateProfileString(section, "SaveLastDir", profile, file);
  502.     if (save_dir) {
  503.         getcwd(profile, sizeof(profile));
  504.         WritePrivateProfileString(section, "LastDir", profile, file);
  505.     }
  506.     WritePrivateProfileString(section, "Ghostscript", szGSwin, file);
  507.     if (device_name[0] != '\0') {
  508.         sprintf(profile,"%s,%s",device_name,device_resolution);
  509.         WritePrivateProfileString(section, "Printer", profile, file);
  510.     }
  511.     for (i=0; i<NUMSOUND; i++)
  512.         WritePrivateProfileString(section, sound[i].entry, sound[i].file, file);
  513. }
  514.  
  515.